﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ApiDemo
{
    /// <summary>
    /// 开启数据过滤器
    /// </summary>
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class SqlFilterAttribute : Attribute
    {
        /// <summary>
        /// 过滤器名称
        /// </summary>
        public string FilterName { set; get; }
        /// <summary>
        /// 过滤sql语句
        /// </summary>
        public string Sql { set; get; }
        /// <summary>
        /// 参数
        /// </summary>
        public object Parameters { set; get; }
        /// <summary>
        /// 是单表查询还是多表查询
        /// </summary>
        public bool IsJoinQuery { set; get; }
        /// <summary>
        /// 初始化过滤器
        /// </summary>
        /// <param name="filtername"></param>
        /// <param name="sql"></param>
        /// <param name="parameters"></param>
        /// <param name="isJoinQuery"></param>
        public SqlFilterAttribute(String filtername, string sql, string parameters, bool isJoinQuery=false)
        {
            this.FilterName = filtername;
            this.Sql = sql;
            this.Parameters = parameters;
            this.IsJoinQuery = isJoinQuery;
        }

    }
}
